Drop down box & text box issue |
Drop down box & text box issue |
beadedtrinketsbyangie |
Jun 28 2007, 08:29 PM
Post
#1
|
Group: Members Posts: 1 Joined: 28-June 07 Member No.: 3,229 |
I have a website with a drop down box that I want to drive how many text boxes I have available. If my customer chooses the first selection it will give them 10 text boxes, if they choose the second selection it will give them 20 text boxes and so on. Does anyone have an idea as to how to make that happen. I have searched everywhere and haven't been able to come up with anything. Thanks to anyone who can help me.
|
lavazza |
Jun 28 2007, 11:01 PM
Post
#2
|
Member Group: Members Posts: 60 Joined: 25-June 07 Member No.: 3,191 |
I have a website with a drop down box that I want to drive how many text boxes I have available. If my customer chooses the first selection it will give them 10 text boxes, if they choose the second selection it will give them 20 text boxes and so on. Does anyone have an idea as to how to make that happen. I have searched everywhere and haven't been able to come up with anything. Thanks to anyone who can help me. Javascript is ideally suited to this Your controls (textboxes and dropdown list) must be contained within a form Change the type of each of the 20 input boxes from type="text" to type="hidden" Ensure that each of the 20 input boxes has a unique name Incorporate an onChange event to fire a javascript function that changes the relevant inputs from type="hidden" to type="text" e.g.
<script type="text/javascript">
</script> |
Darin McGrew |
Jun 28 2007, 11:12 PM
Post
#3
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
For a version that works when JavaScript is disabled/unavailable, you'll need to have the form generated by a server-side (e.g., CGI, PHP) program. Next to the SELECT element will be a submit button to commit whatever it is the SELECT element specifies. When that submit button is used, then the server-side program returns another form with the same data that was in the first one, except the number of text boxes is different.
JavaScript can be used to avoid the round-trip to the server, as lavazza explained. |
lavazza |
Jun 30 2007, 08:15 AM
Post
#4
|
Member Group: Members Posts: 60 Joined: 25-June 07 Member No.: 3,191 |
For a version that works when JavaScript is disabled/unavailable... Thanks Darin! That reminded me that I had forgotten a <noscript> section... Which, in turn, made me realise that my declaration of the function is WRONG!!!! function (changeTypeToText) is WRONG... it should be function changeTypeToText() ----------- One way of writing the <select> so that it is visible only to visitors WITH javascript enabled: CODE <body> <!-- earlier parts of the body here --> <script type="text/javascript"> document.write('<select name="myDropDownListName" onChange="changeTypeToText();">' + ' <option value="0"> Please select: <\/option> ' + ' <option value="ten"> Ten text boxes <\/option> ' + ' <option value="twenty"> Twenty text boxes<\/option> ' + ' <\/select> ' ); </script> <noscript> To see this section, javascript must be enabled on your browser <br/> <br/> <a href="https://www.google.com/adsense/support/bin/answer.py?answer=12654"> How do I enable JavaScript in my browser?</a> </noscript> <!-- later parts of the body here --> </body> This post has been edited by lavazza: Jun 30 2007, 08:18 AM |
Lo-Fi Version | Time is now: 3rd May 2024 - 11:39 AM |